package com.zhuiyun.project.api.learnPlan.controller;

import com.zhuiyun.project.annotation.OptLog;
import com.zhuiyun.project.api.learnPlan.entity.LearnPlan;
import com.zhuiyun.project.api.learnPlan.entity.Zong;
import com.zhuiyun.project.api.learnPlan.model.LearnPlanModel;
import com.zhuiyun.project.api.learnPlan.service.LearnPlanService;
import com.zhuiyun.project.api.learnPlan.service.ZongService;
import com.zhuiyun.project.api.poetryAuthor.model.PoetryAuthorModel;
import com.zhuiyun.project.common.controller.BaseController;
import com.zhuiyun.project.common.errorCode.CommonException;
import com.zhuiyun.project.common.response.CommonResult;
import com.zhuiyun.project.utils.constants.CommonConstants;
import com.zhuiyun.project.utils.pageUtil.PageRequest;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName LearnPlanConreoller
 * @Description TODO 学习计划模块
 * @Author zuo
 * @Date 2023/12/19 9:29
 */
@RestController
@RequestMapping("/plan")
@Slf4j
public class LearnPlanConreoller extends BaseController {

    @Autowired
    private LearnPlanService learnPlanService;

    @Resource
    private ZongService zongService;

    /**
     * @Author 学习计划列表查询
     * @Description
     * @Date 2023/12/19 9：30
     * @Return
     * @param
     */
    @GetMapping("/selectall")
    @OptLog(modular = "学习计划", type = CommonConstants.SELECT, describe = "查询学习计划")
    @ApiOperation(value = "学习计划列表")
    private CommonResult selectall(@RequestBody LearnPlan learnPlan){
        System.out.println(learnPlan);
        System.out.println("418944444444444444444444448888888888888888888888888888888888888888888888888888888888");
        return learnPlanService.selectall(learnPlan);

    }


    /**
     * @Author zf
     * @Date 2024/2/23 8:51 TODO 添加学习计划小程序端
     * @param  learnPlanModel
     * @return CommonResult
     */
    @PostMapping("insertPlanQ")
    @OptLog(modular = "学习计划管理",type = CommonConstants.ADD,describe = "添加学习计划")
    @ApiOperation(value = "添加学习计划")
    public CommonResult InsertPlanQ(@RequestBody LearnPlanModel learnPlanModel) throws CommonException {
        return learnPlanService.insertPlanQ(learnPlanModel);
    }


    /**
     *
     * @Author shy
     * @Date 2023/12/11 13:42 TODO 模糊分页查询学习计划
     * @param learnPlanModel
     * @return CommonResult
     */
    @GetMapping("selectPage")
    @OptLog(modular = "学习计划",type = CommonConstants.SELECT,describe = "查询学习计划")
    @ApiOperation(value = "查询学习计划")
    public CommonResult selectPage(LearnPlanModel learnPlanModel, PageRequest pageRequest){
        return zongService.ListLearnPlan(learnPlanModel,pageRequest);
    }
}
